/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights
 * reserved. <a>http://www.cqcis.com</a>
 */
package com.cq.bd.dwr;

import java.util.List;
import java.util.Map;

import com.cq.base.domain.Page;
import com.cq.bd.base.BaseDwr;
import com.cq.bd.domain.SRole;
import com.cq.bd.domain.SRoleFunction;
import com.cq.bd.service.RoleService;

/**
 * 角色管理
 * 
 * @author huangmy
 * @date   2009-10-5
 */
public class RoleDwr extends BaseDwr {
    private static final long serialVersionUID = 1L;
    private RoleService roleService;

    /**
     * 创建角色
     * 
     * @param role
     */
    public void createRole(SRole role) {
        this.roleService.doCreateRole(role);
    }
    
    /**
     * 修改角色
     * 
     * @param role
     */
    public void updateRole(SRole role) {
        this.roleService.doUpdateRole(role);
    }
    
    /**
     * 获取所有的角色
     * 
     * @return
     */
    public List<SRole> getRoles() {
        return this.roleService.doGetRoles();
    }
    
    /**
     * 获取所有的角色
     * 
     * @return
     */
    public SRole getRole(Long roleId) {
        return this.roleService.doGetRole(roleId);
    }
    
    /**
     * 删除角色
     * 
     * @param roleId
     */
    public void deleteRole(Long roleId) {
        this.roleService.doDeleteRole(roleId);
    }
    
    /**
     * 分页查询
     * 
     * @param filter
     * @param like
     * @param sort
     * @param pageNo
     * @param pageSize
     * @return
     */
    public Page pageRoles(Map<String, String> filter, Map<String, String> like, Map<String, String> sort, int pageNo, int pageSize){
        return this.roleService.pageRoles(filter, like, sort, pageNo, pageSize);    
    }
    
    /**
     * 角色与权限关联
     * 
     * @param roleFunc
     */
    public void createRoleFuncs(List<SRoleFunction> roleFuncs) {
        this.roleService.doCreateRoleFuncs(roleFuncs);
    }
    
    /**
     * 角色所关联的权限
     * 
     * @param roleId
     * @return
     */
    public List<SRoleFunction> getFuncsOfRole(Long roleId) {
        return this.roleService.doGetFuncsOfRole(roleId);
    }
    
    /**
     * 角色与权限关联
     * 
     * @param roleFunc
     */
    public void createRoleFunc(SRoleFunction roleFunc) {
        this.roleService.doCreateRoleFunc(roleFunc);
    }
    
    /**
     * 删除角色与权限关联
     * 
     * @param roleFunc
     */
    public void deleteRoleFuncs(List<SRoleFunction> roleFuncs) {
        this.roleService.doDeleteRoleFuncs(roleFuncs);
    }
    
    /**
     * 删除角色与权限关联
     * 
     * @param roleFunc
     */
    public void removeRoleFunc(SRoleFunction roleFunc) {
        this.roleService.doRemoveRoleFunc(roleFunc);
    }

    public void setRoleService(RoleService roleService) {
        this.roleService = roleService;
    }
}
